using System;
using System.Diagnostics;
using System.Collections.Generic;
using System.Text;
using System.Text.RegularExpressions;
using System.Xml;
using My.IdlConverter.Core.Filters;

namespace My.IdlConverter.Com
{
    using Path = System.IO.Path;

    class ComClassFilter : IClassFilter
    {
        public virtual bool Match(string name)
        {
            string filterFile = My.IdlConverter.Core.Cfg.Configuration.FilterSettingPath;
            XmlDocument doc = new XmlDocument();
            doc.Load(filterFile);
            XmlNode node = doc.SelectSingleNode("//filters/class_filter");
            Debug.Assert(node.InnerText.Length > 0);
            string[] filterClass = node.InnerText.Split(new char[] { ';'});
            foreach (string nextFilterClass in filterClass)
            {
                if (Regex.IsMatch(name, nextFilterClass))
                    return true;
            }

            return false;
        }
    }
}
